﻿using System;
using System.Collections.Generic;
using System.Linq;

//内容包括订单号，顾客，以及订单明细


namespace order_project
{
    public class Order
    {
        public int OrderId { get; set; }
        public string Customer { get; set; }
        public List<OrderDetail> OrderDetails { get; set; } = new List<OrderDetail>();

        public override bool Equals(object obj)
        {
            if (obj is Order order)
            {
                return OrderId == order.OrderId;
            }
            return false;
        }

        public override int GetHashCode()
        {
            return OrderId.GetHashCode();
        }

        public override string ToString()
        {
            return $"OrderID: {OrderId}, Customer: {Customer}, Total Amount: {OrderDetails.Sum(od => od.UnitPrice * od.Quantity)}";
        }

        public decimal TotalAmount()
        {
            return OrderDetails.Sum(item => item.UnitPrice * item.Quantity);
        }
    }



}
